//
//  CAnAlgSwimLapData.m
//  sr01sdkProject
//
//  Created by  on 2024/9/3.
//

#import "CAnAlgSwimLapData.h"

@implementation CAnAlgSwimLapData

-(NSNumber *)dataTimeStamp
{
    return @(self.timeStamp);
}

- (instancetype)initWithData:(NSData *)data
{
    self = [super init];
    if (self) {
        
        if (data.length < 20) {
            return self;
        }
        
        uint8_t *dataBytes = (uint8_t *)[data bytes];
        _cmdByte = dataBytes[1];
        // 四字节时间戳
        uint32_t timeStamp = *((uint32_t *)(dataBytes + 2));
        _timeStamp = timeStamp;
        _strokes = *((uint16_t *)(dataBytes + 6));// 单圈划水次数
        _lapSwimDuration = *((uint16_t *)(dataBytes + 8));// 游泳时间 s

        _strokeRate = dataBytes[10];
        _swimStylePerLap = dataBytes[11];
        
        _lapSwimPace = *((uint16_t *)(dataBytes + 12));//dataBytes[12];
        
        _swolf = *((uint16_t *)(dataBytes + 14));
        _lapDetectionStatus = dataBytes[16];
        _lapDistance = dataBytes[17];
    }
    return self;
}
@end
